package org.example;

import java.sql.*;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection cn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/paqu", "root", "1234");
            System.out.println(cn);
            //String mu="select *from result where 品种名称=?";
            //模糊查询
            String mu="select *from result where name  like ?";
           // String mu="delete from logind where uername= ? and pasword= ?";
//            String mu = "select * from result where name = limit ?,?";
           // String mu="select *from result where name not like ?";
            //String mu="insert into result(品种名称,链接)values (?,?)";
            PreparedStatement ps = cn.prepareStatement(mu);
//           ps.setInt(1, 3);
//            ps.setInt(2, 3);
            ps.setString(1,"小米");
            /**ps.setString(1,"小米");
            ps.setString(2,"wwwf");
            int c=ps.executeUpdate();
            System.out.println(c);
             **/
            //int c=ps.executeUpdate();
            //System.out.println(c);
            System.out.println("你好");
            ResultSet rs = ps.executeQuery();
            System.out.println(rs);
        while(rs.next()) {
               String qq=rs.getString("name")+" "+
                         rs.getString("charst");
               System.out.println(qq);


};



            cn.close();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}